package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Eric
 * @version v1.0
 * @package com.leyou.item.mapper
 * @date 2019/6/24 21:31
 * @description:
 **/
public interface BrandMapper extends BaseMapper<Brand> {
    /**
     * 新增中间表数据
     * @param id
     * @param ids
     * @return
     */
    int insertCategoryBrand(@Param("id") Long id, @Param("ids") List<Long> ids);

    @Delete("delete from tb_category_brand where brand_id=#{id}")
    void deleteCategoryBrand(@Param("id") Long id);

    @Select("select tb.id,tb.name,tb.image,tb.letter from tb_brand tb left join tb_category_brand tcb on tb.id=tcb.brand_id where tcb.category_id=#{cid}")
    List<Brand> queryByCid(@Param("cid") Long cid);
}
